package org.demo.db.meta.impl;

import java.lang.reflect.Constructor;

import org.demo.db.meta.DbMeta;

/**
 * 工厂类：用来 create *MetaImpl
 * @author  
 * @date    2010-9-7
 * @file    org.loushang.db.meta.impl.DbMetaFactory.java
 */
public class DbMetaFactory {
	private static String className = "org.loushang.db.meta.impl.";
	/**
	 * 创建实现类
	 * @param dbType
	 * @param driver
	 * @param url
	 * @param user
	 * @param password
	 * @return
	 * @throws Exception
	 */
	public static DbMeta create(
			String dbType,
			String driver,String url,
			String user,String password)throws Exception{
		DbMeta instance = null;
		Class<?> impl = Class.forName(className + dbType + "MetaImpl");
		Constructor<?> cons = impl.getConstructor(
				                     String.class,String.class,
				                     String.class,String.class);
		instance = (DbMeta)cons.newInstance(driver,url,user,password);
		return instance;
	}
}
